package cn.jobstart.service.impl;

import cn.jobstart.vo.ResumeIntershipMiniDomainVO;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import cn.jobstart.modelExt.ResumeIntershipExt;
import cn.jobstart.dao.IResumeIntershipDao;
import cn.jobstart.searchExt.ResumeIntershipSearchExt;
import cn.jobstart.pubInter.IBaseDao;
import cn.jobstart.pubInter.AbstractBaseService;
import cn.jobstart.service.IResumeIntershipService;
import lombok.extern.slf4j.Slf4j;
import cn.jobstart.common.StringUtil;
import cn.jobstart.common.SkList;
import cn.jobstart.pubInter.exception.SkException;

import java.util.List;


/**
 * @author sunke
 * @Date 2023-09-06 15:00:21
 * @description ResumeIntershipService      实习经历
 */
@Service(value = "resumeIntershipService")
@Slf4j
public class ResumeIntershipServiceImpl extends AbstractBaseService<ResumeIntershipExt, ResumeIntershipSearchExt, String> implements IResumeIntershipService {

    @Resource(name = "resumeIntershipDao")
    private IResumeIntershipDao resumeIntershipDao;

    @Override
    public IBaseDao<ResumeIntershipExt, ResumeIntershipSearchExt, String> getDao() {
        return resumeIntershipDao;
    }


    /**
     * 实习经历
     *
     * @param resumeId
     * @return
     */
    @Override
    public String getIntershipStrByResumeId(String resumeId) {
        try {
            List<ResumeIntershipExt> list = getListByResumeId(resumeId);

            return StringUtil.getJsonArrayStrByList(list, ResumeIntershipMiniDomainVO.class);


        } catch (Exception e) {

        }
        return "";
    }

    /**
     * 根据简历ID 得到列表
     *
     * @param resumeId
     * @return
     */
    @Override
    public List<ResumeIntershipExt> getListByResumeId(String resumeId) {
        if (StringUtil.isNullOrEmpty(resumeId)) {
            return null;
        }
        try {
            return getAllList(ResumeIntershipSearchExt.getInstance().setResumesIdEq(resumeId));
        } catch (SkException e) {
            return null;
        }
    }
}